﻿using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using com.guojin.mj.net.message;
using UnityEngine.SceneManagement;
using com.guojin.mj.net.message.login;
using com.guojin.mj.net.message.game;
using com.guojin.mj.net.message.club;
using com.guojin.core.io.message;
using System;

public class JoinRoomPage : EventManager {   

    private static JoinRoomPage instance;
    public static JoinRoomPage GetInstance()
    {
        return instance;
    }
    void Awake()
    {
        instance = this;
    }

    public Text[] textgroup;
    public static int index = 0;

    public override void InformationSetting()
    {
        index = 0;
        roomID = "";
    }

    string roomID;
    private void UpdateInputRoomNum(int num) {
           //LoginAndShare.Controller.BtnVoice();
            textgroup[index].text = num.ToString();
            index++;
            if (textgroup[5].text != "" && textgroup[5].text != null)
            {
                for (int i = 0; i < textgroup.Length; i++)
                {
                    roomID += textgroup[i].text;
                    textgroup[i].text = "";
                }

                MessageManager.GetInstance().SendMsg76(roomID);
                index = 0;
                roomID = "";
            }
    }

    public void Get0() {
        Debug.Log(0);
        this.UpdateInputRoomNum(0);
    }
    public void Get1() {
        this.UpdateInputRoomNum(1);
    }
    public void Get2() {
        this.UpdateInputRoomNum(2);
    }
    public void Get3() {
        this.UpdateInputRoomNum(3);
    }
    public void Get4() {
        this.UpdateInputRoomNum(4);
    }
    public void Get5() {
        this.UpdateInputRoomNum(5);
    }
    public void Get6() {
        this.UpdateInputRoomNum(6);
    }
    public void Get7() {
        this.UpdateInputRoomNum(7);
    }
    public void Get8() {
        this.UpdateInputRoomNum(8);
    }
    public void Get9() {
        this.UpdateInputRoomNum(9);
    }

    public void Backspace()                  //退格
    {
        //LoginAndShare.Controller.BtnVoice();
        if (index>0)
        {
            index--;
            textgroup[index].text = "";      
        }
    }

    public void Clear()                          //清除
    {
        //LoginAndShare.Controller.BtnVoice();
        for (int i = 0; i < textgroup.Length; i++)
        {
            textgroup[i].text = "";
        }
        index = 0;
        roomID = "";      
    }

    public void CloseBtnClick()
    {
        Destroy(transform.gameObject);
    }
}
